package com.aaa.methodreference.demo01;

import java.util.function.Consumer;

/**
 * @author C-Q
 * @version 1.1.0
 * @Description: TODO
 * @date 2022/11/4
 */
public class Test01 {
    public static void main(String[] args) {
        //void accept(T t);

        /*Consumer<int[]> consumer=(arr)->{
            Test01.sum(arr);};*/
        Consumer<int[]> consumer=Test01::sum;

        int[] arr={2,4,5,7,2,5,1};
        consumer.accept(arr);
    }
    public static void sum(int[] arr){
        int sum=0;
        for (int i : arr) {
            sum+=i;
        }
        System.out.println("数组中元素的和："+sum);
    }
}
